﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Contracts;

namespace FatHibernation.Utilities.DesignByContract
{
    public class Check
    {


        public static void Require(bool precondition)
        {
            Require(precondition, "Precondition not met!");
        }

        public static void Require(bool precondition, string errorMessage)
        {
            if (!precondition)
                throw new PreconditionException(errorMessage);
        }

        public static void Ensure(bool postCondition, string errorMessage)
        {
            if (!postCondition)
                throw new PostconditionException(errorMessage);
        }

    }
}
